<?php
/**
 * @file: Sphinxm.php
 * @User: shiwuhao
 * @Date: 16/4/21 10:58
 * @synopsis: coreseek 返回实例 单例
 */

class Sphinxm extends CI_Model
{
    private static $_instance = NULL;

    function __construct(){
        parent::__construct();
    }

    private function __clone(){}

    /**
     * 获得类实例
     * @return null|SphinxClient
     */
    public function getInstance($host = 'localhost', $port = 9324)
    {
        if (self::$_instance == NULL) {
            $this->load->library('Sphinxclient');
            self::$_instance = new SphinxClient();
            self::$_instance->SetServer($host, $port);
            self::$_instance->SetConnectTimeout(1);
            self::$_instance->SetArrayResult(true);
        }

        return self::$_instance;
    }
}